# //////////////////////////////////////////////////////////////////////////////
# //
# // Copyright © 1998-2024 Glodon Company Limited.
# //
# // Licensed under the MIT License
# //
# // Permission is hereby granted, free of charge, to any person obtaining a
# // copy of this software and associated documentation files (the “Software”),
# // to deal in the Software without restriction, including without limitation
# // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# // sell copies of the Software, and to permit persons to whom the Software is
# // furnished to do so, subject to the following conditions:
# //
# // The above copyright notice and this permission notice shall be included in
# // all copies or substantial portions of the Software.
# //
# // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# //
# //////////////////////////////////////////////////////////////////////////////


cmake_minimum_required(VERSION 3.11)
project(ComponentEditorGnufUI)

set(CMAKE_CONFIGURATION_TYPES "Debug;Release") 
set(CMAKE_CXX_FLAGS "/DWIN64 /D_WINDOWS /D_USRDLL /Zi /nologo /W3 /WX /MP  /EHsc -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS /wd4250 /wd4251") 
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /MD /DNDEBUG") 
set(CMAKE_CXX_FLAGS_DEBUG "/Od /MDd /D_DEBUG") 
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /INCREMENTAL") 
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEBUG ") 

# QT
set(QTDIR_X64 $ENV{QTDIR_X64})
set(QTDIR_X64_include "${QTDIR_X64}/include" CACHE PATH "")
set(QTDIR_X64_include_QtCore "${QTDIR_X64}/include/QtCore" CACHE PATH "")
set(QTDIR_X64_include_QtWidgets "${QTDIR_X64}/include/QtWidgets" CACHE PATH "")
set(QTDIR_X64_include_QtGui "${QTDIR_X64}/include/QtGui" CACHE PATH "")
set(QTDIR_X64_lib "${QTDIR_X64}/lib" CACHE PATH "")

# COMPONENTEDITOR_SDK
if(DEFINED ENV{COMPONENTEDITOR_SDK_DIR})
    set(COMPONENTEDITOR_SDK $ENV{COMPONENTEDITOR_SDK_DIR} CACHE PATH  "Directory of ComponentEditor_SDK")
else ()
    set(COMPONENTEDITOR_SDK "" CACHE PATH  "Directory of ComponentEditor_SDK")
endif()

if(COMPONENTEDITOR_SDK STREQUAL "")
message("COMPONENTEDITOR_SDK NOTFOUND")
else()
message("COMPONENTEDITOR_SDK  ---- " ${COMPONENTEDITOR_SDK})
endif()

# ComponentEditorGnufUI
set(TARGET_NAME ComponentEditorGnufUI) 
add_definitions(-DCOMPONENT_EDITOR_GNUF_UI_HOME) 

# Find includes in corresponding build directories 
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Find the Qt library
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)

# Turn on automatic invocation of the MOC, UIC & RCC
set(CMAKE_AUTOMOC ON) 
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source)

# Resource Files
qt5_add_resources(RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/resource/ComponentEditorGnufUI.qrc)

# All Files
file(GLOB SourceRootFiles ${SOURCE_DIR}/*.cpp ${SOURCE_DIR}/*.h) 
source_group("" FILES ${SourceRootFiles}) 

set(Commands ${SOURCE_DIR}/Commands) 
file(GLOB CommandsFiles ${Commands}/*.*) 
source_group("Commands" FILES ${CommandsFiles}) 

set(CustomerService ${SOURCE_DIR}/CustomerService) 
file(GLOB CustomerServiceFiles ${CustomerService}/*.*) 
source_group("CustomerService" FILES ${CustomerServiceFiles}) 

set(DisplayAndPickFilter ${SOURCE_DIR}/DisplayAndPickFilter) 
file(GLOB DisplayAndPickFilterFiles ${DisplayAndPickFilter}/*.*) 
source_group("DisplayAndPickFilter" FILES ${DisplayAndPickFilterFiles}) 

set(Filter ${SOURCE_DIR}/Filter) 
file(GLOB FilterFiles ${Filter}/*.*) 
source_group("Filter" FILES ${FilterFiles}) 

set(MainWindow ${SOURCE_DIR}/MainWindow) 
file(GLOB MainWindowFiles ${MainWindow}/*.*) 
source_group("MainWindow" FILES ${MainWindowFiles}) 

set(Manager ${SOURCE_DIR}/Manager) 
file(GLOB ManagerFiles ${Manager}/*.*) 
source_group("Manager" FILES ${ManagerFiles}) 

set(ModelView ${SOURCE_DIR}/ModelView) 
file(GLOB ModelViewFiles ${ModelView}/*.*) 
source_group("ModelView" FILES ${ModelViewFiles}) 

set(PropertyPallet ${SOURCE_DIR}/PropertyPallet)
file(GLOB PropertyPalletFiles ${PropertyPallet}/*.*) 
source_group("PropertyPallet" FILES ${PropertyPalletFiles}) 

set(UI ${SOURCE_DIR}/UI)
file(GLOB UIFiles ${UI}/*.*) 
source_group("UI" FILES ${UIFiles}) 

set(UrlConfig ${SOURCE_DIR}/UrlConfig)
file(GLOB UrlConfigFiles ${UrlConfig}/*.*) 
source_group("UrlConfig" FILES ${UrlConfigFiles}) 

set(Utility ${SOURCE_DIR}/Utility)
file(GLOB UtilityFiles ${Utility}/*.*) 
source_group("Utility" FILES ${UtilityFiles}) 

include_directories(${SOURCE_DIR} ${Commands} ${CustomerService} ${DisplayAndPickFilter} ${Filter} ${MainWindow} ${Manager} ${ModelView} ${PropertyPallet} ${UI} ${UrlConfig} ${Utility})

set(SOURCE_FILES ${SourceRootFiles} ${CommandsFiles} ${CustomerServiceFiles} ${DisplayAndPickFilterFiles} ${FilterFiles} ${MainWindowFiles} ${ManagerFiles} ${ModelViewFiles} ${PropertyPalletFiles} ${UIFiles} ${UrlConfigFiles} ${UtilityFiles}) 

add_library(${TARGET_NAME} SHARED ${SOURCE_FILES}) 

add_definitions(-DQT_DLL -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB ) 

target_include_directories(${TARGET_NAME} PRIVATE ${COMPONENTEDITOR_SDK}/include)
target_include_directories(${TARGET_NAME} PRIVATE ${QTDIR_X64_include})
target_include_directories(${TARGET_NAME} PRIVATE ${QTDIR_X64_include_QtCore})
target_include_directories(${TARGET_NAME} PRIVATE ${QTDIR_X64_include_QtWidgets})
target_include_directories(${TARGET_NAME} PRIVATE ${QTDIR_X64_include_QtGui})

target_link_directories(${TARGET_NAME} PRIVATE ${COMPONENTEDITOR_SDK}/lib/${CMAKE_BUILD_TYPE})
target_link_directories(${TARGET_NAME} PRIVATE ${QTDIR_X64_lib})

target_link_libraries(${TARGET_NAME} 
pugixml.lib 
GcmpDevService.lib 
GcmpCommandInterface.lib 
GcmpFoundation.lib 
GcmpGuiMainFrameInterface.lib 
GcmpGUiBaseInterface.lib 
GcmpApplicationInterface.lib 
GcmpJournalInterface.lib 
GcmpDatabaseInterface.lib 
GcmpDatabase.lib 
GcmpMathInterface.lib 
GcmpUiViewInterface.lib 
GcmpActionInterface.lib 
GcmpGuiInterface.lib 
GcmpPickInterface.lib 
GcmpGraphicsNodeInterface.lib 
GcmpModel.lib 
GcmpUiInterface.lib 
GcmpSnapInterface.lib 
GmFamilyService.lib 
GmModelFamily.lib 
GmInplaceEdit.lib 
GmUiInplaceEditCommon.lib 
GnufAssistant.lib 
GnufInterface.lib 
GcmpUiBase.lib 
GnufBase.lib 
GnufExtension.lib 
GmUiCommonComponent.lib 
GcmpGuiInterface.lib 
GmFamilyService.lib 
GcmpDevService.lib 
GcmpModel.lib 
GSolver.lib 
GcmpGeometryInterface.lib 
GcmpDatabase.lib 
GcmpGraphicsNode.lib 
GcmpCommandAction.lib 
GcmpDbCommonEdit.lib 
ExprEngine.lib 
GmModelFamily.lib 
GcmpModelInterface.lib 
GcmpRenderingInterface.lib 
GmFamilyUtils.lib 
GmFamilyDataStandard.lib 
GmFamilyDatabase.lib 
ComponentEditorGnufUiInterface.lib 
ComponentEditorUIBase.lib 
debug Qt5Cored.lib 
debug Qt5Widgetsd 
debug Qt5Guid.lib 
debug Qt5AxBased.lib 
debug Qt5AxContainerd.lib 
debug Qt5Networkd.lib 
optimized Qt5Core.lib 
optimized Qt5Widgets.lib 
optimized Qt5Gui.lib 
optimized Qt5AxBase.lib 
optimized Qt5AxContainer.lib 
optimized Qt5Network.lib 
)
 
